<?php
require_once("inc.admin.php");

$this_title="$vars[title] &raquo; ".__("Arbitrage Result");
$page_title=__("Arbitrage Result");

$td_width=180;

 //#####UPDATE TO DB#####if($post_d['__req']=='1'){
 if(!$errmsg){
  $sql="update $db->settings set value='$post_d[result_date]' where param='result_date' limit 1";
  if(!mysql_query($sql)){
   $errmsg.=__("We have encountered some error and the update result date process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[over_30_days]' where param='over_30_days' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update over 30 days process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[result1]' where param='result1' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update result 1 process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[result2]' where param='result2' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update result 2 process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[result3]' where param='result3' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update result 3 process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[result4]' where param='result4' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update result 4 process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[result5]' where param='result5' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update result 5 process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[day1]' where param='day1' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update day 1 process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[day2]' where param='day2' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update day 2 process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[day3]' where param='day3' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update day 3 process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[day4]' where param='day4' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update day 4 process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[day5]' where param='day5' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update day 5 process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[arbs]' where param='arbs' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update arbs process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[all_profit]' where param='all_profit' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update all profit process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[investor_profit]' where param='investor_profit' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update investor profit process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[company_profit]' where param='company_profit' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update company profit process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[expenses]' where param='expenses' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update expenses process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[fund_increase]' where param='fund_increase' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update fund increase process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[en_result]' where param='en_result' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update English result process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }    $sql="update $db->settings set value='$post_d[cn_result]' where param='cn_result' limit 1";  if(!mysql_query($sql)){   $errmsg.=__("We have encountered some error and the update Chinese result process has been failed.").($vars["debug"]? "<br />\n<br />\nSQL: $sql<br />\n<br />\nError: ".mysql_error() : "")."<br />\n";  }
  if(!$errmsg){
   $msg=format_msg(__("You have successfully updated settings."));
   }
  }
}
 $errmsg=$errmsg? format_err($errmsg) : "";
$result_date=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='result_date'"));$over_30_days=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='over_30_days'"));$result1=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='result1'"));$result2=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='result2'"));$result3=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='result3'"));$result4=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='result4'"));$result5=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='result5'"));$day1=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='day1'"));$day2=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='day2'"));$day3=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='day3'"));$day4=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='day4'"));$day5=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='day5'"));$arbs=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='arbs'"));$all_profit=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='all_profit'"));$investor_profit=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='investor_profit'"));$company_profit=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='company_profit'"));$expenses=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='expenses'"));$fund_increase=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='fund_increase'"));$en_result=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='en_result'"));$cn_result=mysql_fetch_assoc($r=mysql_query("select value from $db->settings where param='cn_result'"));
$profile=($errmsg || $msg?
"$errmsg $msg" : "")."
<form name='profile_form' method='post' action='$this_file'>
<input type='hidden' name='__req' value='1' />
<table class='amt_table'>
 <tr>
  <td width='$td_width'>Result Date:</td>
  <td><input type='text' name='result_date' value=\"$result_date[value]\" $inputbox_style /></td>    
 </tr> <tr>  <td width='$td_width'>Over 30 Days:</td>  <td><input type='text' name='over_30_days' value=\"$over_30_days[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>Result 1:</td>  <td><input type='text' name='result1' value=\"$result1[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>Result 2:</td>  <td><input type='text' name='result2' value=\"$result2[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>Result 3:</td>  <td><input type='text' name='result3' value=\"$result3[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>Result 4:</td>  <td><input type='text' name='result4' value=\"$result4[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>Result 5:</td>  <td><input type='text' name='result5' value=\"$result5[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>Day 1:</td>  <td><input type='text' name='day1' value=\"$day1[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>Day 2:</td>  <td><input type='text' name='day2' value=\"$day2[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>Day 3:</td>  <td><input type='text' name='day3' value=\"$day3[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>Day 4:</td>  <td><input type='text' name='day4' value=\"$day4[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>Day 5:</td>  <td><input type='text' name='day5' value=\"$day5[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>Arbs:</td>  <td><input type='text' name='arbs' value=\"$arbs[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>All Profit:</td>  <td><input type='text' name='all_profit' value=\"$all_profit[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>Investor Profit:</td>  <td><input type='text' name='investor_profit' value=\"$investor_profit[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>Company Profit:</td>  <td><input type='text' name='company_profit' value=\"$company_profit[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>Expenses:</td>  <td><input type='text' name='expenses' value=\"$expenses[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>Fund Increase:</td>  <td><input type='text' name='fund_increase' value=\"$fund_increase[value]\" $inputbox_style /></td>     </tr> <tr>  <td width='$td_width'>English Result:</td>  <td><textarea name='en_result' $inputbox_style rows='5' />$en_result[value]</textarea></td>     </tr> <tr>  <td width='$td_width'>Chinese Result:</td>  <td><textarea name='cn_result' $inputbox_style rows='5' />$cn_result[value]</textarea></td>     </tr>
 <tr>
  <td colspan='2' class='center' style='padding:20px 0 20px 0;'>
   <input type='submit' value=\"".__("Update")."\" />
  </td>
 </tr>
</table></form>";

$content=
"<h2>$page_title</h2>
$profile";

print format_admin_page($content, $this_title);
?>